package com.xiao.login.vm

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

/**
 * 简化liveData使用方式
 */
open class BaseViewModel<T>:ViewModel() {

    open fun handleIntent(intent:T){}


    /**
     * 只能在kt中使用
     * 可读可写
     */
    @JvmSynthetic
    protected fun <K> LiveData<K>.mutate():MutableLiveData<K> {
        return this as MutableLiveData<K>
    }

    /**
     * 仅可读
     */
    @JvmSynthetic
    protected fun <K> MutableLiveData<K>.immutate():LiveData<K>{
        return this as LiveData<K>
    }

}